package com.flxz.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.flxz.common.annotation.Log;
import com.flxz.common.core.controller.BaseController;
import com.flxz.common.core.domain.AjaxResult;
import com.flxz.common.enums.BusinessType;
import com.flxz.manage.domain.ManageUserIncome;
import com.flxz.manage.service.IUserIncomeService;
import com.flxz.common.utils.poi.ExcelUtil;
import com.flxz.common.core.page.TableDataInfo;

/**
 * 用户收入（管理员)Controller
 * 
 * @author ruoyi
 * @date 2025-09-12
 */
@RestController
@RequestMapping("/manage/incomeAdmin")
public class UserIncomeAdminController extends BaseController
{
    @Autowired
    private IUserIncomeService userIncomeService;

    /**
     * 查询用户收入（管理员)列表
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManageUserIncome userIncome)
    {
        startPage();
        List<ManageUserIncome> list = userIncomeService.selectUserIncomeList(userIncome);
        return getDataTable(list);
    }

    /**
     * 导出用户收入（管理员)列表
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:export')")
    @Log(title = "用户收入（管理员)", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManageUserIncome userIncome)
    {
        List<ManageUserIncome> list = userIncomeService.selectUserIncomeList(userIncome);
        ExcelUtil<ManageUserIncome> util = new ExcelUtil<ManageUserIncome>(ManageUserIncome.class);
        util.exportExcel(response, list, "用户收入（管理员)数据");
    }

    /**
     * 获取用户收入（管理员)详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:query')")
    @GetMapping(value = "/{incomeId}")
    public AjaxResult getInfo(@PathVariable("incomeId") Long incomeId)
    {
        return success(userIncomeService.selectUserIncomeByIncomeId(incomeId));
    }

    /**
     * 新增用户收入（管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:add')")
    @Log(title = "用户收入（管理员)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManageUserIncome userIncome)
    {
        return toAjax(userIncomeService.insertUserIncome(userIncome));
    }

    /**
     * 修改用户收入（管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:edit')")
    @Log(title = "用户收入（管理员)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManageUserIncome userIncome)
    {
        return toAjax(userIncomeService.updateUserIncome(userIncome));
    }

    /**
     * 删除用户收入（管理员)
     */
    @PreAuthorize("@ss.hasPermi('manage:incomeAdmin:remove')")
    @Log(title = "用户收入（管理员)", businessType = BusinessType.DELETE)
	@DeleteMapping("/{incomeIds}")
    public AjaxResult remove(@PathVariable Long[] incomeIds)
    {
        return toAjax(userIncomeService.deleteUserIncomeByIncomeIds(incomeIds));
    }
}
